/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.uniminuto.arqSw.ejercicio.DAO;

import co.edu.uniminuto.arqSw.ejercicio.Hibernate.Cliente;
import co.edu.uniminuto.arqSw.ejercicio.Hibernate.HibernateUtil;
import co.edu.uniminuto.arqSw.ejercicio.Hibernate.Video;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author JULIAN
 */
public class LoginDAO {
Session session = null;
String user = null;
String pass = null;

public LoginDAO(String S, String P) {
this.session = HibernateUtil.getSessionFactory().openSession();                
user=S;
pass=P;
}

public Cliente getUser(){
Cliente miCliente=new Cliente();

try{
   
    Transaction tx = session.beginTransaction();
    tx.begin();
    Query q= session.createQuery("from Cliente where id_cliente=:id and password=:ps");
    q.setParameter("id",user);
    q.setParameter("ps", pass);
    miCliente = (Cliente)q.uniqueResult();
tx.commit();
}catch(Exception e){
e.printStackTrace();
}
session.close();
return miCliente;
}

}
